package ch.ffhs.bscinf2009.organizeanything.data;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;

@SuppressWarnings("javadoc")
public class DatabaseServiceMock extends DatabaseService{

	public DatabaseServiceMock(Context context) {
		super(context);
	}
	
	public void generateTestData(){
		
		generateBooks();
		generateMovies();
		
	}

	private void generateMovies() {
		saveDefintion(book("dvds", null,null));
		addEntry(book("dvds", "Equilibrium", "Sci-Fi"), book("dvds", "Die Hard", "Action"), book("dvds", "hard to die", "Action"));
	}

	private void generateBooks() {
		saveDefintion(book("books", null,null));
		addEntry(book("books", "Harry Potter1", "Sci-Fi"), book("books", "Lustiger Taschenbuch LTB23", "Cartoon"), book("books", "Jerry Cotton", "Thriller"));
	}

	private Organizable book(String organizable, String title, String type) {
		Organizable b1 = new Organizable();
		b1.setOrganizableName(organizable);
		
		List<AbstractType> props  = new ArrayList<AbstractType>();
		StringType s = new StringType();
		s.setPropertyName("Title");
		s.setDescriptorValue(true);
		if(title!=null){
			s.setData(title);
		}
		
		ValueChooserType v = new ValueChooserType();
		v.setDescriptorValue(false);
		v.setPropertyName("Genre");
		v.parseTypeDefinition("Sci-Fi;Thriller;Cartoon;Comedy;Action");
		if(type!=null){
			v.setData(type);
		}
		
		props.add(s);
		props.add(v);
		b1.setProperties(props);
		return b1;
	}

}
